package com.gee.spring.cloud.aerospace.simulate.core.groovy;

import org.codehaus.groovy.control.CompilerConfiguration;
import org.codehaus.groovy.control.customizers.ImportCustomizer;

/**
 * @author gepengjun
 * @since 2022/11/24 10:15
 */
public class GroovyCompileConfig {

    private static final CompilerConfiguration compilerConfiguration = initConfig();

    private static CompilerConfiguration initConfig() {
        CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
        ImportCustomizer importCustomizer = new ImportCustomizer();
        importCustomizer.addStarImports(
                "com.gee.spring.cloud.common.core.domain.dsl",
                "com.gee.spring.cloud.common.core.domain.telemetry",
                "com.gee.spring.cloud.common.core.entity.center.config",
                "com.gee.spring.cloud.telemetry.parse.core.util",
                "com.gee.spring.cloud.telemetry.parse.core.telemetry",
                "com.gee.spring.cloud.common.core.domain.dsl",
                "com.gee.spring.cloud.telemetry.parse.core.exception",
                "com.gee.spring.cloud.telemetry.parse.core.constant",
                "java.time",
                "java.time.temporal",
                "cn.hutool.core.util",
                "cn.hutool.core.date",
                "cn.hutool.core.bean",
                "com.gee.spring.cloud.protobuf",
                "com.google.protobuf",
                "io.netty.buffer"

        );
        compilerConfiguration.addCompilationCustomizers(importCustomizer);
        return compilerConfiguration;
    }

    public static CompilerConfiguration getInstance(){
        return compilerConfiguration;
    }

    private GroovyCompileConfig() {
    }
}
